package com.lyxs916.testlibrary.rxjavatest;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.lyxs916.testlibrary.R;
import com.lyxs916.testlibrary.rxjavatest.retrofittext.TRetrofitTest;

import butterknife.ButterKnife;


/**
 * 说明:RxJava与Retrofit 测试页
 * 作者： 杨阳; 创建于：  2017-06-06  12:33
 */
public class TRRMainActivity extends Activity {


    public static void startUi(Context context) {
        Intent intent = new Intent(context, TRRMainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        context.startActivity(intent);
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test_activity_main);
        ButterKnife.bind(this);

        //rxJava测试
        findViewById(R.id.rxJava).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TRxAndroidTest rt = new TRxAndroidTest();
//                rt.test1();
//                rt.test2();
//                rt.test3();
                rt.test4();

            }
        });

        //retrofit测试
        findViewById(R.id.retrofit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                TRetrofitTest retrofitTest = new TRetrofitTest();
                try {
                    retrofitTest.sendRequest();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //Retrofit+Rxjava测试
        findViewById(R.id.retrofit2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                TRetrofitTest retrofitTest = new TRetrofitTest();
                try {
                    retrofitTest.sendRequest2();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //Retrofit+Rxjava测试并发
        findViewById(R.id.retrofit3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                TRetrofitTest retrofitTest = new TRetrofitTest();
                try {
                    retrofitTest.sendRequest3();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //Retrofit+Rxjava测试路径
        findViewById(R.id.retrofit4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                TRetrofitTest retrofitTest = new TRetrofitTest();
                try {
                    retrofitTest.sendRequest4();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //Retrofit+Rxjava测试路径get
        findViewById(R.id.retrofit5).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                TRetrofitTest retrofitTest = new TRetrofitTest();
                try {
                    retrofitTest.sendRequest5();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //使用httpManager管理类调用
        findViewById(R.id.retrofit6).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                TRetrofitTest retrofitTest = new TRetrofitTest();
                try {
                    retrofitTest.sendRequest6();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        //使用httpManager管理类调用
        findViewById(R.id.retrofit7).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                TRetrofitTest retrofitTest = new TRetrofitTest();
                try {
                    retrofitTest.sendRequest7();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }


}
